cmake_minimum_required(VERSION 2.8.3)
project(dispatch_system)

add_compile_options(-std=c++17)
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
SET(CMAKE_BUILD_TYPE Release)
#SET(CMAKE_BUILD_TYPE Debug)
find_package(catkin REQUIRED COMPONENTS
  moying_costmap
  moying_proto
  commu_with_sm
  sch_common
  schedule_config
)
find_package(log4cplus)

if(NOT DEFINED $log4cplus_LIBRARIES)
  set( log4cplus_LIBRARIES "/usr/local/lib/liblog4cplus.so")
endif()

MESSAGE( STATUS "log4cplus_LIBRARIES: ${log4cplus_LIBRARIES}")

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES dispatch_system
  CATKIN_DEPENDS moying_costmap moying_proto commu_with_sm sch_common schedule_config
  DEPENDS system_lib
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME}
  src/${PROJECT_NAME}/moying_map.cpp
  src/${PROJECT_NAME}/vehicle.cpp
  src/${PROJECT_NAME}/time_based_astar.cpp
  src/${PROJECT_NAME}/diff_drive_vehicle.cpp
  src/${PROJECT_NAME}/mecanum_vehicle.cpp
  src/${PROJECT_NAME}/custom_movepatterns.cpp
  src/${PROJECT_NAME}/map_pretreatment.cpp
  src/${PROJECT_NAME}/local_costmap.cpp
  src/${PROJECT_NAME}/one_way_road.cpp
)

target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
  sch_common
  commu_with_sm
  ${log4cplus_LIBRARIES}
)

# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

# add_executable(${PROJECT_NAME}_node src/dispatch_system_node.cpp)

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
#   ${catkin_LIBRARIES}
# )


#配置包含的头文件（安装后可在/opt/ros/kinetic/include/${PROJECT_NAME}路径下找到该头文件）
install(DIRECTORY include/${PROJECT_NAME}/

  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}

)

## Mark executables and/or libraries for installation
install(TARGETS ${PROJECT_NAME} 
   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)
